"""
MonoNeurona 2008
GPLv3

Coatl -- CMS
"""
from django.db import models
from datetime import datetime 
from django.contrib.auth.models import User
from django.contrib.sites.models import Site 
from django.core.mail import send_mail
from django.utils.translation import ugettext as _
from django.contrib.syndication.feeds import Feed
import Image

class Category(models.Model):
   category    = models.CharField(max_length=30, unique=True)
   description = models.CharField(max_length=100, unique=True)
   image       = models.ImageField(upload_to='img/themes')

   def __unicode__(self):
       return u'%s %s' % (self.category, self.description)

class News(models.Model):
  author     = models.ForeignKey(User, verbose_name=_('Author'),editable=False)
  date       = models.DateTimeField(default=datetime.now())
  title      = models.CharField(max_length=100)
  slug       = models.SlugField(unique=True)
  reference  = models.URLField(verify_exists=True, max_length=300)
  new        = models.TextField()
  status     = models.BooleanField(default=True, verbose_name='Published')
  discussion = models.BooleanField(default=True, verbose_name='Comments allowed')
  category   = models.ForeignKey(Category)
  
  def __unicode__(self):
       return self.title

class Discussion(models.Model):
  author    = models.ForeignKey(User, editable=False)
  date      = models.DateTimeField(datetime.now(), editable=False)
  email     = models.EmailField(max_length=60)
  website   = models.CharField(max_length=100)
  comment   = models.TextField()
  status    = models.BooleanField(default=True)
 
class NewsFeed(Feed):
  title = "Coatl News Feed"
  link = "/news/"
  description = "My random thoughts and musings on a variety of subjects."
  def items(self):
    return get_items("news")
